package lms.service.impl;

import lms.dao.BorrowDao;
import lms.dao.impl.BorrowDaoImpl;
import lms.entity.Borrow;
import lms.service.BorrowService;

import java.util.List;

/**
 * @description:
 * @author: Grape_Pip
 * @time: 2021/06/24
 */
public class BorrowServiceImpl implements BorrowService {
    public BorrowDao borrowDaoImpl = new BorrowDaoImpl();

    @Override
    public boolean addedBorrowInfo(Borrow bo) {
        if (bo == null) {
            return false;
        }
        int res = borrowDaoImpl.addBorrowInfo(bo);
        if (res == 1) {
            return true;
        } else {
            return false;
        }

    }

    @Override
    public boolean updateReturnBook(int bid, int rid, Borrow bo) {

        int res = borrowDaoImpl.updateReturnInfo(bid, rid, bo);
        if (res == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public List<Borrow> selectedAllBorrowInfo() {
        return borrowDaoImpl.selectBorrowInfo();
    }

    @Override
    public Borrow selectedBorrowByBRid(int bid, int rid) {
        return borrowDaoImpl.selectBoByBidAndRid(bid, rid);
    }

    @Override
    public boolean selectedByRid(int rid) {
        Borrow res = borrowDaoImpl.selectedBoByRid(rid);
        if (res == null) {
            return false;
        }else {
            return true;
        }
    }

    @Override
    public boolean selectedByBid(int bid) {
        Borrow res = borrowDaoImpl.selectedBoByBid(bid);
        if (res == null) {
            return false;
        }else {
            return true;
        }
    }
}
